const lessonFrom = document.getElementById('lessonFrom');
const lessonTo = document.getElementById('lessonTo');
const author = document.getElementById('author');

function aa(){
    chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
        let v1 = lessonFrom.value;
        let v2 = lessonTo.value;
        if(v1 && v2){
            let message = { start: true, lessonFrom:v1*1, lessonTo:v2*1 };
            // 向content scripts发送消息
            chrome.tabs.sendMessage(tab.id, message, (res) => {
                document.getElementById('app').innerHTML = res;//imgList;
            });
        }
    });
}

function toUrl(){
    chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
        let message = { url:author.href };
        // 向content scripts发送消息
        chrome.tabs.sendMessage(tab.id, message, (res) => {
            // document.getElementById('app').innerHTML = res;//imgList;
        });
    });
}


lessonFrom.addEventListener('input', async () => {
    aa()
});
lessonTo.addEventListener('input', async () => {
    aa()
});
author.addEventListener('click', async () => {
    toUrl()
});
